# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
# See COPYING for license details.

pkgname=clusterd
pkgver=143.d190b2c
pkgrel=5
groups=('blackarch' 'blackarch-automation')
pkgdesc='Automates the fingerprinting, reconnaissance, and exploitation phases of an application server attack.'
url='https://github.com/hatRiot/clusterd'
arch=('any')
license=('MIT')
depends=('python2' 'python2-requests' 'java-environment')
makedepends=('git')
source=("git+https://github.com/hatRiot/$pkgname.git")
sha512sums=('SKIP')

pkgver() {
  cd $pkgname

  echo $(git rev-list --count HEAD).$(git rev-parse --short HEAD)
}

package() {
  cd $pkgname

  install -dm 755 "$pkgdir/usr/bin/"

  install -Dm 755 "$pkgname.py" "$pkgdir/usr/share/$pkgname/$pkgname.py"
  install -Dm 644 -t "$pkgdir/usr/share/doc/$pkgname/" README.md
  install -Dm 644 LICENSE "$pkgdir/usr/share/licenses/$pkgname/LICENSE"

  rm LICENSE README.md

  cp -a src "$pkgdir/usr/share/$pkgname/"

  chmod u+rwX,g+rwX,o+rX -R "$pkgdir/usr/share/$pkgname/src"

  cat > "$pkgdir/usr/bin/$pkgname" << EOF
#!/bin/sh
cd /usr/share/$pkgname
exec python2 $pkgname.py "\$@"
EOF

  chmod +x "$pkgdir/usr/bin/$pkgname"
}

